package com.zhengtoudai.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zhengtoudai.R;
import com.zhengtoudai.ui.bean.MyRedpacketModel;
import com.zhengtoudai.util.DensityUtil;
import com.zhengtoudai.view.recyclerview.RecyclerViewAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 我的红包
 */

public class MyRedpacketAdapter extends RecyclerViewAdapter<MyRedpacketAdapter.ViewHolder, MyRedpacketModel.MyRedpacketBean.RedListEntity> {


    @Override
    public ViewHolder mOnCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_my_redpacket, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void mOnBindViewHolder(ViewHolder holder, int position) {
        if (position == 0) {
            holder.itemView.setPadding(0, DensityUtil.dip2px(mContext, 10), 0, 0);
        } else {
            holder.itemView.setPadding(0, 0, 0, 0);
        }
        holder.mTvTitle.setText(data.get(position).getActivityName());
        holder.mTvMoney.setText(data.get(position).getRedMoney());
        holder.mTvDate.setText(data.get(position).getAddTime());
        holder.mTvContent.setText(data.get(position).getDescription());
    }


    static class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_title)
        TextView mTvTitle;
        @Bind(R.id.tv_money)
        TextView mTvMoney;
        @Bind(R.id.tv_content)
        TextView mTvContent;
        @Bind(R.id.tv_date)
        TextView mTvDate;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
